<?php
$script_name = $_SERVER['SCRIPT_NAME'];
$tmp = explode('/',$script_name);
$uri_data = array(
	'written_language_tag' => $tmp[1],
	'category_name' => $tmp[3],
);
$where = $_GET;
$limit_start = $_GET['limit_start'];
unset($where['limit_start']);
$limit_size = $_GET['limit_size'];
unset($where['limit_size']);
$order_by = isset($_GET['order_by']) ? $_GET['order_by'] : '';
unset($where['order_by']);
$product_model = new ProductModel($uri_data['category_name'], $uri_data['written_language_tag']);
$products_id = $product_model->getProductsId($where,$limit_start,$limit_size,$order_by);
$detail = $product_model->getProductsDetail($products_id);
$preview_img = $product_model->getProductsFileUri($products_id,'preview_img');
foreach($products_id as $id)
{
	$data[$id] = array(
		'id' => $id,
		'img' => $preview_img[$id],
		'name' => $detail[$id],
	);
}
$v['data'] = $data;
output($v);
exit;
?>
